home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / crimfght.c < prev    next >
C/C++ Source or Header  |  2000-01-10  |  3KB  |  113 lines

  1. #include "driver.h"
  2. #include "vidhrdw/generic.h"
  3. #include "vidhrdw/konamiic.h"
  4.  
  5.  
  6. static int layer_colorbase[3],sprite_colorbase;
  7.  
  8. /***************************************************************************
  9.  
  10.   Callbacks for the K052109
  11.  
  12. ***************************************************************************/
  13.  
  14. static void tile_callback(int layer,int bank,int *code,int *color)
  15. {
  16.     tile_info.flags = (*color & 0x20) ? TILE_FLIPX : 0;
  17.     *code |= ((*color & 0x1f) << 8) | (bank << 13);
  18.     *color = layer_colorbase[layer] + ((*color & 0xc0) >> 6);
  19. }
  20.  
  21. /***************************************************************************
  22.  
  23.   Callbacks for the K051960
  24.  
  25. ***************************************************************************/
  26.  
  27. static void sprite_callback(int *code,int *color,int *priority)
  28. {
  29.     /* Weird priority scheme. Why use three bits when two would suffice? */
  30.     /* The PROM allows for mixed priorities, where sprites would have */
  31.     /* priority over text but not on one or both of the other two planes. */
  32.     /* Luckily, this isn't used by the game. */
  33.     switch (*color & 0x70)
  34.     {
  35.         case 0x10: *priority = 0; break;
  36.         case 0x00: *priority = 1; break;
  37.         case 0x40: *priority = 2; break;
  38.         case 0x20: *priority = 3; break;
  39.         /*   0x60 == 0x20 */
  40.         /*   0x50 priority over F and A, but not over B */
  41.         /*   0x30 priority over F, but not over A and B */
  42.         /*   0x70 == 0x30 */
  43.     }
  44.     /* bit 7 is on in the "Game Over" sprites, meaning unknown */
  45.     /* in Aliens it is the top bit of the code, but that's not needed here */
  46.     *color = sprite_colorbase + (*color & 0x0f);
  47. }
  48.  
  49.  
  50. /***************************************************************************
  51.  
  52.     Start the video hardware emulation.
  53.  
  54. ***************************************************************************/
  55.  
  56. void crimfght_vh_stop( void )
  57. {
  58.     free(paletteram);
  59.     K052109_vh_stop();
  60.     K051960_vh_stop();
  61. }
  62.  
  63. int crimfght_vh_start( void )
  64. {
  65.     paletteram = malloc(0x400);
  66.     if (!paletteram) return 1;
  67.  
  68.     layer_colorbase[0] = 0;
  69.     layer_colorbase[1] = 4;
  70.     layer_colorbase[2] = 8;
  71.     sprite_colorbase = 16;
  72.     if (K052109_vh_start(REGION_GFX1,NORMAL_PLANE_ORDER,tile_callback))
  73.     {
  74.         free(paletteram);
  75.         return 1;
  76.     }
  77.     if (K051960_vh_start(REGION_GFX2,NORMAL_PLANE_ORDER,sprite_callback))
  78.     {
  79.         free(paletteram);
  80.         K052109_vh_stop();
  81.         return 1;
  82.     }
  83.  
  84.     return 0;
  85. }
  86.  
  87.  
  88.  
  89. /***************************************************************************
  90.  
  91.   Display refresh
  92.  
  93. ***************************************************************************/
  94.  
  95. void crimfght_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  96. {
  97.     K052109_tilemap_update();
  98.  
  99.     palette_init_used_colors();
  100.     K051960_mark_sprites_colors();
  101.     if (palette_recalc())
  102.         tilemap_mark_all_pixels_dirty(ALL_TILEMAPS);
  103.  
  104.     tilemap_render(ALL_TILEMAPS);
  105.  
  106.     K052109_tilemap_draw(bitmap,1,TILEMAP_IGNORE_TRANSPARENCY);
  107.     K051960_sprites_draw(bitmap,2,2);
  108.     K052109_tilemap_draw(bitmap,2,0);
  109.     K051960_sprites_draw(bitmap,1,1);
  110.     K052109_tilemap_draw(bitmap,0,0);
  111.     K051960_sprites_draw(bitmap,0,0);
  112. }
  113.